/*
 * @Author: xiaosihan 
 * @Date: 2024-06-23 18:24:15 
 * @Last Modified by: xiaosihan
 * @Last Modified time: 2024-10-02 00:01:37
 */

import { autorun } from "mobx";
import { ReactNode, useEffect, useRef, useState } from "react";
import styles from "./model3d.module.less";
import model3dRender from "./model3dRender";
import LeftContorl from "./LeftContorl/LeftContorl";
import TopContorl from "./TopContorl/TopContorl";
import BottomContorl from "./BottomContorl/BottomContorl";
import partCollaborateStore from "../partCollaborateStore";
import { Spin } from "antd";
import CubeControl from "./CubeControl/CubeControl";
import clsx from "clsx";
import ShowCommentBtn from "./ShowCommentBtn/ShowCommentBtn";
import rightPlaneStore from "../RightPlane/rightPlaneStore";
import DragModel from "./DragModel/DragModel";
import ModelTree from "./ModelTree/ModelTree";
import ModelBlast from "./ModelBlast/ModelBlast";
import CommentModal from "./CommentModal/CommentModal";
import rightPlaneDemoStore from "@views/pc/PartCollaborateDemo/RightPlaneDemo/rightPlaneDemoStore";
import RightMenu from "./RightMenu/RightMenu";
import Profile from "./Profile/Profile";
import ModelMeasure from "./ModelMeasure/ModelMeasure";
import MeasureLength from "./MeasureLength/MeasureLength";
import MeasureVolume from "./MeasureVolume/MeasureVolume";
import MeasureThickness from "./MeasureThickness/MeasureThickness";
import MeasureBox from "./MeasureBox/MeasureBox";

interface Iprops {
    children?: ReactNode
}

// 3d 模型展示
export default function Model3d() {

    const dom = useRef<HTMLDivElement | null>(null);
    const [loadding, setLoadding] = useState(partCollaborateStore.loadding);
    const [rightPlaneShow, setRightPlaneShow] = useState(rightPlaneStore.show);
    const isDemo = (location.hash === "#/partCollaborateDemo");
    useEffect(() => {

    }, []);

    useEffect(() => autorun(() => {
        setLoadding(partCollaborateStore.loadding);
        setRightPlaneShow((isDemo ? rightPlaneDemoStore : rightPlaneStore).show);
    }), []);

    return (
        <div className={clsx(styles.model3d, rightPlaneShow && styles.show)} >
            {loadding && <Spin className={styles.spin} size="large" />}

            <div className={styles.container} ref={dom => model3dRender.setContainer(dom)} ></div>

            {/* 顶部控制器 */}
            <TopContorl />

            {/* 底部控制器 */}
            <BottomContorl />

            {/* 方位控制器 */}
            <CubeControl />

            {/* 显示评论按钮 */}
            <ShowCommentBtn />

            {/* 评论标点组件 */}
            <CommentModal />

            {/* 模型树 */}
            <ModelTree />

            {/* 模型爆炸图 */}
            <ModelBlast />

            {/* 剖面图 */}
            <Profile />

            {/* 模型测量 */}
            <ModelMeasure />

            {/* 测量距离 */}
            <MeasureLength />

            {/* 测量体积 */}
            <MeasureVolume />

            {/* 测量壁厚 */}
            <MeasureThickness />

            {/* 包围盒 */}
            <MeasureBox />

            {/* 右键菜单 */}
            <RightMenu />

        </div>
    );

}